
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
 <meta charset="utf-8">
 <title>发展党员列表</title>
 <meta name="renderer" content="webkit">
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 <link rel="stylesheet" href="../layui/css/layui.css" th:href="@{../layui/css/layui.css}" media="all">
<link href="favicon.ico" rel="shortcut icon">
</head>
<script th:src="@{../layui/layui.js}" charset="utf-8"></script>
<body>
<table class="layui-hide" id="demo" lay-filter="test"></table>

<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm" lay-event="getCheckData">添加</button>
  </div>
</script>
<!-- 分页组件 -->
<div>
    <div id="page_container"></div>
</div>

<script>
layui.use('table', function(){
	  var table = layui.table;
//执行一个 table 实例
	table.render({
	  elem: '#demo'
	  ,height: 'full-80'
	  ,url: 'dmdlist' //数据接口
	  ,even:true //开启隔行换色
	  ,title: '发展党员表'
	  ,cellMinWidth:100 
	  ,toolbar:'#toolbarDemo'  //开启工具栏
	  ,cols: [
		  [ //表头
		{type: 'checkbox', fixed: 'left'}
		,{field: 'dmnum', title: '序号',}
        ,{field: 'name', title: '姓名',}
        ,{field: 'sex', title: '性别', sort: true}
        ,{field: 'workUnit', title: '工作单位'} 
        ,{field: 'stageName', title: '当前阶段'} 
        ,{field: 'nextStageName', title: '下一阶段'} 
	    ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
	  ]
		]
	});
	//头工具栏事件
	  table.on('toolbar(test)', function(obj){
		layer.open({
			type:1,
			title:'添加用户',
			area:'800px',
			anim: 1,
			skin: 'layui-layer-molv',
			content:layui.$('#add')
		})
		 
		  
	  });
	
});
</script>
<!-- 添加 -->
<form id="add" class="layui-form" action="adddm" lay-filter="example" method="post" hidden="true">
  <div class="layui-form-item">
    <label class="layui-form-label">序号</label>
    <div class="layui-input-block">
      <input type="text" name="dmnum" lay-verify="title" autocomplete="off" placeholder="请输入用户序号" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-block">
      <input type="text" name="name" placeholder="请输入用户真实姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">民族</label>
    <div class="layui-input-block">
      <input type="text" name="nation" placeholder="请输入民族" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">性别 </label>
    <div class="layui-input-block">
      <input type="radio" name="sex" value="男" title="男" checked="">
      <input type="radio" name="sex" value="女" title="女">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">身份证号</label>
    <div class="layui-input-block">
      <input type="text" name="idnum" placeholder="请输入用户身份证号" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">学历</label>
    <div class="layui-input-block">
      <input type="text" name="education" placeholder="请输入学历信息" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">工作单位</label>
    <div class="layui-input-block">
      <input type="text" name="workUnit" placeholder="请输入用户工作单位" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">工作岗位</label>
    <div class="layui-input-block">
      <input type="text" name="workJob" placeholder="请输入用户工作岗位" autocomplete="off" class="layui-input">
    </div>
  </div>

 <div class="layui-form-item">
    <label class="layui-form-label">岗位类型</label>
    <div class="layui-input-block">
      <select name="workJobType" lay-filter="aihao">
      	<option value="党政机关工作人员" selected="">党政机关工作人员</option>
        <option value="国企员工">国企员工</option>
        <option value="非国企员工">非国企员工</option>
        <option value="在校大学生">在校大学生</option>
      </select>
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">家庭住址</label>
    <div class="layui-input-block">
      <input type="text" name="familyAddress" placeholder="请输入用户家庭住址" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">图片</label>
    <div class="layui-input-block">
      <input type="text" name="pic" placeholder="请输入图片" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <!-- <div class="layui-form-item">
    <label class="layui-form-label">免冠照片</label>
    <div class="layui-input-block">
      <div class="layui-upload">
		  <button type="button" class="layui-btn" id="test1">上传图片</button>
		  <div class="layui-upload-list">
		    <img class="layui-upload-img" id="demo1">
		    <p id="demoText"></p>
		  </div>
	  </div> 
    </div>
  </div> -->
  
    <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<!-- 修改 -->
<form id="update" class="layui-form layui-form-pane" action="dmupdate" lay-filter="formTest" method="post" hidden="true" style="height800px;">
  
  <div class="layui-form-item" hidden="true">
    <label class="layui-form-label">bid</label>
    <div class="layui-input-block">
      <input type="text" name="bid" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">序号</label>
    <div class="layui-input-block">
      <input type="text" name="dmnum" lay-verify="title" autocomplete="off" placeholder="请输入用户序号" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-block">
      <input type="text" name="name" placeholder="请输入用户真实姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">民族</label>
    <div class="layui-input-block">
      <input type="text" name="nation" placeholder="请输入民族" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">性别 </label>
    <div class="layui-input-block">
      <input type="radio" name="sex" value="男" title="男" checked="">
      <input type="radio" name="sex" value="女" title="女">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">身份证号</label>
    <div class="layui-input-block">
      <input type="text" name="idnum" placeholder="请输入用户身份证号" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">学历</label>
    <div class="layui-input-block">
      <input type="text" name="education" placeholder="请输入学历信息" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">工作单位</label>
    <div class="layui-input-block">
      <input type="text" name="workUnit" placeholder="请输入用户工作单位" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">工作岗位</label>
    <div class="layui-input-block">
      <input type="text" name="workJob" placeholder="请输入用户工作岗位" autocomplete="off" class="layui-input">
    </div>
  </div>

 <div class="layui-form-item">
    <label class="layui-form-label">岗位类型</label>
    <div class="layui-input-block">
      <select name="workJobType" lay-filter="aihao">
      	<option value="党政机关工作人员" selected="">党政机关工作人员</option>
        <option value="国企员工">国企员工</option>
        <option value="非国企员工">非国企员工</option>
        <option value="在校大学生">在校大学生</option>
      </select>
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">家庭住址</label>
    <div class="layui-input-block">
      <input type="text" name="familyAddress" placeholder="请输入用户家庭住址" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">图片</label>
    <div class="layui-input-block">
      <input type="text" name="pic" placeholder="请输入图片" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <!-- <div class="layui-form-item">
    <label class="layui-form-label">免冠照片</label>
    <div class="layui-input-block">
      <div class="layui-upload">
		  <button type="button" class="layui-btn" id="test1">上传图片</button>
		  <div class="layui-upload-list">
		    <img class="layui-upload-img" id="demo1">
		    <p id="demoText"></p>
		  </div>
	  </div> 
    </div>
  </div> -->
  
    <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

<!-- 进入下一阶段 提交会议资料-->
<form id="addinfo" class="layui-form" action="addinfo" lay-filter="addinformation" method="post" hidden="true">
  
  <div class="layui-form-item" hidden="true">
    <label class="layui-form-label">bid</label>
    <div class="layui-input-block">
      <input type="text" name="bid" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
    </div>
  </div>
    
  <div class="layui-form-item" hidden="true">
    <label class="layui-form-label">mtid</label>
    <div class="layui-input-block">
      <input type="text" name="mtid" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">递交申请书时间</label>
    <div class="layui-input-block">
      <input type="date" name="createTime" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
    </div>
    
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">支部会议时间</label>
    <div class="layui-input-block">
      <input type="date" name="meetingTime" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">应到人数</label>
    <div class="layui-input-block">
      <input type="text" name="shouldNum" placeholder="请输入应到人数" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">实到人数</label>
    <div class="layui-input-block">
      <input type="text" name="realNum" placeholder="请输入实到人数" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">讨论结果</label>
    <div class="layui-input-block">
      <input type="text" name="meetingResult" placeholder="同意/驳回" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">第一培养人姓名</label>
    <div class="layui-input-block">
      <input type="text" name="firstRec" placeholder="请输入第一培养人姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">第一培养人职务</label>
    <div class="layui-input-block">
      <input type="text" name="firstRecPosition" placeholder="请输入职务" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">第二培养人姓名</label>
    <div class="layui-input-block">
      <input type="text" name="secondRec" placeholder="请输入第二培养人姓名" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">第二培养人职务</label>
    <div class="layui-input-block">
      <input type="text" name="secondRecPosition" placeholder="请输入职务" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">上传会议图片</label>
    <div class="layui-input-block">
      <input type="text" name="meetingNum" placeholder="请上传图片" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">会议照片</label>
    <div class="layui-input-block">
		<div class="layui-upload">
		  <button type="button" class="layui-btn" id="test2">多图片上传</button> 
		  <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
		    预览图：
		    <div class="layui-upload-list" id="demo2"></div>
		 </blockquote>
		</div>
    </div>
  </div>
  
    <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<!-- 分页栏目 -->
<script>
layui.use('laypage', function(){
  var laypage = layui.laypage;
  //执行一个laypage实例
  laypage.render({
    elem: 'page_container' 
    	,count: 26
    	,skip: true //开启跳页
        ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
        ,jump: function(obj,first){
        	if(!first){
                layer.msg('第'+ obj.curr +'页', {offset: 'b'});
              }
        }
  });
});
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="update">修改</a>
  <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="addinfo">进入下一阶段</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
layui.use(['table','form'], function(){
  var table = layui.table;
  var form = layui.form;
  //监听表格复选框选择
  table.on('checkbox(test)', function(obj){
    console.log(obj)
  });
  //监听工具条
  table.on('tool(test)', function(obj){ 
    var data = obj.data;
    if(obj.event === 'update'){
    	layui.form.render('select')
    	//1.获取这行数据
    	//2.填充form
    	form.val("formTest",data);
    	/**1.首先需要获取复选框原始的值
    	2.将这个值在页面上展示
    	*/
    	var state=data.state;
    	if(state=="禁用"){
    		layui.$("#sel").val(2);
    	}else{
    		layui.$("#sel").val(1);
    	} 
    	form.render('select','selFilter'); 
    	//3.弹框
    	layer.open({
    		type:1,
			title:'修改用户',
			area:'800px',
			anim: 1,
			skin: 'layui-layer-molv',
			content:layui.$('#update'),	
    	}); 
    } else if(obj.event === 'addinfo'){
    	var bid = data.bid;
    	var mtid = data.dmsid;
    	form.val('addinformation',{
    		"bid": bid
    		,"mtid": mtid
    	});
    	layer.open({
    		type:1,
			title:'确定资格会议资料',
			area:'800px',
			anim: 1,
			skin: 'layui-layer-molv',
			content:layui.$('#addinfo'),	
    	}); 
    	
    }else if(obj.event === 'del'){
      layer.confirm('是否删除数据',{icon:3,title:"确认"}, function(index){
    	  layui.$.ajax({
              url:"dmdelete",
              type:"POST",
              data:{"bid":data.bid},
              dataType: "json",                
              success: function(data){            
              if(data.id==null){    
            	  layer.msg("删除失败", {icon: 5});              
              }else{
                  layer.msg(data.id);
                  obj.del();//删除这一行
                  layer.close(index);//关闭弹框
                  layer.msg("删除成功", {icon: 6}); 
              	}
              },
              error:function(){
            	  layer.closeAll();
                  parent.location.reload();;//调用父级的layer来关闭弹窗
                  Load(); //删除完需要加载数据
              },
    	  });
      });
    };
    
	layui.use('upload', function(){
	  var $ = layui.jquery
	  ,upload = layui.upload;
	  
	  //普通图片上传
	  var uploadInst = upload.render({
	    elem: '#test1'
	    ,url: 'upload'
	    ,before: function(obj){
	      //预读本地文件示例，不支持ie8
	      obj.preview(function(index, file, result){
	        $('#demo1').attr('src', result); //图片链接（base64）
	      });
	    }
	    ,done: function(res){
	      //如果上传失败
	      if(res.code > 0){
	        return layer.msg('上传失败');
	      }
	      //上传成功
	    }
	    ,error: function(){
	      //演示失败状态，并实现重传
	      var demoText = $('#demoText');
	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
	      demoText.find('.demo-reload').on('click', function(){
	        uploadInst.upload();
	      });
	    }
	  });
	  
	  //多图片上传
	  upload.render({
	    elem: '#test2'
	    ,url: '/upload/'
	    ,multiple: true
	    ,before: function(obj){
	      //预读本地文件示例，不支持ie8
	      obj.preview(function(index, file, result){
	        $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
	      });
	    }
	    ,done: function(res){
	      //上传完毕
	    }
	  });
	  
	});
  });
});
</script>


</body>
</html>